# -*- coding: UTF-8 -*-
# @Date ：2024/7/4 16:33
# @File：sessions
# @Author：mmmme
# @IDE：PyCharm
from sqlalchemy import create_engine, Column, String, Text
from sqlalchemy.orm import Session, registry
from sqlalchemy.orm import sessionmaker

Base = registry().generate_base()
metadata = Base.metadata


class Risk_analysis_unit(Base):
    __tablename__ = 'risk_analysis_unit'
    __table_args__ = {'comment': '安全风险分析单元'}
    id = Column(String, primary_key=True)
    companyName = Column(String)
    companyCode = Column(String)
    data = Column(Text)

    def to_dict(self):
        return {i.name: getattr(self, i.name) for i in self.__table__.columns}


class Risk_event(Base):
    __tablename__ = 'risk_event'
    __table_args__ = {'comment': '安全风险事件'}
    id = Column(String, primary_key=True)
    companyName = Column(String)
    companyCode = Column(String)
    data = Column(Text)

    def to_dict(self):
        return {i.name: getattr(self, i.name) for i in self.__table__.columns}


class Risk_control_measures(Base):
    __tablename__ = 'risk_control_measures'
    __table_args__ = {'comment': '安全风险管控措施'}
    id = Column(String, primary_key=True)
    companyName = Column(String)
    companyCode = Column(String)
    data = Column(Text)

    def to_dict(self):
        return {i.name: getattr(self, i.name) for i in self.__table__.columns}


class Hazard_detection_task(Base):
    __tablename__ = 'hazard_detection_task'
    __table_args__ = {'comment': '隐患排查任务'}
    id = Column(String, primary_key=True)
    companyName = Column(String)
    companyCode = Column(String)
    data = Column(Text)

    def to_dict(self):
        return {i.name: getattr(self, i.name) for i in self.__table__.columns}


class Hazard_detection_record(Base):
    __tablename__ = 'hazard_detection_record'
    __table_args__ = {'comment': '隐患排查记录'}
    id = Column(String, primary_key=True)
    companyName = Column(String)
    companyCode = Column(String)
    data = Column(Text)

    def to_dict(self):
        return {i.name: getattr(self, i.name) for i in self.__table__.columns}


class Hazard_detection_information(Base):
    __tablename__ = 'hazard_detection_information'
    __table_args__ = {'comment': '隐患排查信息'}
    id = Column(String, primary_key=True)
    companyName = Column(String)
    companyCode = Column(String)
    data = Column(Text)

    def to_dict(self):
        return {i.name: getattr(self, i.name) for i in self.__table__.columns}


class Job_ticket_information(Base):
    __tablename__ = 'job_ticket_information'
    __table_args__ = {'comment': '特殊作业票证信息'}
    id = Column(String, primary_key=True)
    companyName = Column(String)
    companyCode = Column(String)
    data = Column(Text)

    def to_dict(self):
        return {i.name: getattr(self, i.name) for i in self.__table__.columns}


class Person_real_time_location(Base):
    __tablename__ = 'person_real_time_location'
    __table_args__ = {'comment': '人员实时定位'}
    id = Column(String, primary_key=True)
    companyName = Column(String)
    companyCode = Column(String)
    data = Column(Text)

    def to_dict(self):
        return {i.name: getattr(self, i.name) for i in self.__table__.columns}


# sqlite连接初始化
class SqliteSqlalchemy(object):
    def __init__(self):
        path = "/Users/empress./MyWorkSpace/WorkProject/Project/LanTuStudio/dual-system/data_report.db"
        # 创建sqlite连接引擎
        engine = create_engine(f'sqlite:///{path}', echo=True)
        # 创建表
        # Base.metadata.create_all(engine, checkfirst=True)
        # 创建sqlite的session连接对象
        self.session = sessionmaker(bind=engine)()

    def save_risk_analysis_unit(self, db: Session, risk_analysis_units):
        try:
            db.bulk_insert_mappings(Risk_analysis_unit, risk_analysis_units)
            db.commit()
        except Exception as e:
            print(e)
            db.rollback()

    def save_risk_event(self, db: Session, risk_events):
        try:
            db.bulk_insert_mappings(Risk_event, risk_events)
            db.commit()
        except Exception as e:
            db.rollback()

    def save_risk_control_measures(self, db: Session, risk_control_measuress):
        try:
            db.bulk_insert_mappings(Risk_control_measures, risk_control_measuress)
            db.commit()
        except Exception as e:
            db.rollback()

    def save_hazard_detection_task(self, db: Session, hazard_detection_tasks):
        try:
            db.bulk_insert_mappings(Hazard_detection_task, hazard_detection_tasks)
            db.commit()
        except Exception as e:
            db.rollback()

    def save_hazard_detection_record(self, db: Session, hazard_detection_records):
        try:
            db.bulk_insert_mappings(Hazard_detection_record, hazard_detection_records)
            db.commit()
        except Exception as e:
            db.rollback()

    def save_hazard_detection_information(self, db: Session, hazard_detection_informations):
        try:
            db.bulk_insert_mappings(Hazard_detection_information, hazard_detection_informations)
            db.commit()
        except Exception as e:
            db.rollback()

    def save_job_ticket_information(self, db: Session, job_ticket_informations):
        try:
            db.bulk_insert_mappings(Job_ticket_information, job_ticket_informations)
            db.commit()
        except Exception as e:
            db.rollback()

    def save_person_real_time_location(self, db: Session, person_real_time_locations):
        try:
            db.bulk_insert_mappings(Person_real_time_location, person_real_time_locations)
            db.commit()
        except Exception as e:
            db.rollback()

    def check_data_is_exist(self, db: Session, table, id):
        value = db.query(table).filter(Risk_analysis_unit.id == id).first()
        print(value)
        if value:
            return True
        else:
            return False


if __name__ == '__main__':
    # Base.metadata.create_all(engine)
    lp = [{'id': '67ed9df8-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "67ed9df8-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318001", "riskUnitName": "储罐", "hazardDep": "山东亿泰化工科技有限公司", "hazardLiablePerson": "张旭旭", "createDate": "2023-10-16 14:15:30", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:30", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6220f27d-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6220f27d-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "集液罐", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6220ad9b-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6220ad9b-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "真空泵", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6220ba26-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6220ba26-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "湿粒周转仓", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6220c5ec-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6220c5ec-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "网格机", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6220d136-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6220d136-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "皮带机", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6220dc4b-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6220dc4b-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "风机", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6220e735-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6220e735-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "缓冲罐", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6220feda-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6220feda-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "捕集罐", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '62210a35-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "62210a35-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "列管式冷凝器", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6221153a-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6221153a-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "液环真空泵", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '62212065-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "62212065-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "双锥干燥机", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '62212b63-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "62212b63-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "造粒机", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '622136b2-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "622136b2-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "电动葫芦", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '62214260-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "62214260-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "混料机", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '62214fac-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "62214fac-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "加碱机", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '62215aa3-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "62215aa3-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "二硫化碳高位槽", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '6221659a-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "6221659a-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "醇高位槽", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '62217150-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "62217150-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318717", "riskUnitName": "混捏机", "hazardDep": "合成车间", "hazardLiablePerson": "夏海立", "createDate": "2023-10-16 14:15:20", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:20", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb28f79-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb28f79-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "盐水泵", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb2f3a9-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb2f3a9-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "球磨机", "hazardDep": "球磨车间", "hazardLiablePerson": "晁玉友", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb2e2d7-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb2e2d7-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "循环水泵", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb2d241-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb2d241-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "光氧催化装置", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb2c1d2-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb2c1d2-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "环保风机", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb2b13e-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb2b13e-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "螺杆式制冷氨压缩机组", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb2a021-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb2a021-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "蒸发式冷凝器", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb1bcff-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb1bcff-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "蒸汽管道", "hazardDep": "生产部", "hazardLiablePerson": "张连春", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb0d6d0-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb0d6d0-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "液氨管道", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb0eadd-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb0eadd-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "气相色谱仪", "hazardDep": "化验室", "hazardLiablePerson": "赵洪香", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb0fd7d-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb0fd7d-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "电子天平", "hazardDep": "化验室", "hazardLiablePerson": "赵洪香", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb11011-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb11011-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "电热鼓风干燥箱", "hazardDep": "化验室", "hazardLiablePerson": "赵洪香", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb122b4-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb122b4-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "产品仓库", "hazardDep": "生产部", "hazardLiablePerson": "张连春", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb134ac-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb134ac-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "事故应急池", "hazardDep": "生产部", "hazardLiablePerson": "张连春", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb146da-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb146da-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "厂房", "hazardDep": "生产部", "hazardLiablePerson": "刘洪营", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb1589f-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb1589f-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "配电箱配电室", "hazardDep": "维修车间", "hazardLiablePerson": "刘洪营", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb16ae0-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb16ae0-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "变压器", "hazardDep": "维修车间", "hazardLiablePerson": "刘洪营", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb1881c-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb1881c-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "电焊机", "hazardDep": "维修车间", "hazardLiablePerson": "刘洪营", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb199cc-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb199cc-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "乙炔气瓶", "hazardDep": "维修车间", "hazardLiablePerson": "刘洪营", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb1ab38-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb1ab38-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "氧气瓶", "hazardDep": "维修车间", "hazardLiablePerson": "刘洪营", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb0bd01-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb0bd01-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "叉车", "hazardDep": "球磨车间", "hazardLiablePerson": "晁玉友", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb1ce25-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb1ce25-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "消防水泵", "hazardDep": "生产部", "hazardLiablePerson": "刘洪营", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb1e09e-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb1e09e-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "降温循环水潜污泵", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb1f25d-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb1f25d-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "虹吸罐", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb20411-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb20411-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "空气分离器", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb21667-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb21667-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "紧急泄氨器", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb228a3-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb228a3-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "集油器", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb23b6c-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb23b6c-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "储氨罐", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb24c8d-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb24c8d-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "氨液分离器", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb25d35-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb25d35-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "氨油分离器", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb26dce-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb26dce-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "变压吸附制氮机", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'},
          {'id': '5bb27f04-6beb-11ee-953f-02420adede02', 'companyName': '山东亿泰化工', 'companyCode': '371310318',
           'data': '{"id": "5bb27f04-6beb-11ee-953f-02420adede02", "companyCode": "371310318", "hazardCode": "371310318718", "riskUnitName": "玻璃钢冷却塔", "hazardDep": "制冷车间", "hazardLiablePerson": "段明东", "createDate": "2023-10-16 14:15:09", "createBy": "张旭旭", "updateDate": "2023-10-16 14:15:09", "updateBy": "张旭旭", "deleted": "0"}'}]

    db = SqliteSqlalchemy()
    db.save_risk_analysis_unit(db.session, lp)
